import Vue from 'vue'
import FastClick from 'fastclick'
import router from './router'
import store from './vuex/store'

import App from './App'
import * as UtilsFilter from './components/commons/UtilsFilter.js'
import { WechatPlugin, AjaxPlugin, AlertPlugin, ConfirmPlugin, LoadingPlugin } from 'vux'
import deleteExpiryHistory from './components/commons/deleteExpiryHistory'
import deleteLimitedHistory from './components/commons/deleteLimitedHistory'
import raiseinfoUtils from './components/commons/raiseinfoUtils'

Object.keys(UtilsFilter).forEach(key => {
  Vue.filter(key, UtilsFilter[key])
})

Vue.use(WechatPlugin)
Vue.use(AjaxPlugin)
Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)
Vue.use(LoadingPlugin)
Vue.use(deleteExpiryHistory)
Vue.use(deleteLimitedHistory)
Vue.use(raiseinfoUtils)

// 路由开始前执行，过渡载入效果，半秒钟
router.beforeEach(function (to, from, next) {
  // store.commit('updateLoadingStatus', {isLoading: true})
  // setTimeout(
  //   () => {
  //     next()
  //   }, 100
  // )
  next()
})
// 路由结束，改变状态
router.afterEach(function (to) {
  // store.commit('updateLoadingStatus', {isLoading: false})
  // console.log('after')
})

// 点击延迟
FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app-box')
